import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Calendar;
import java.util.HashMap;


public class PizzaBean extends CommonBean {
	private static final long serialVersionUID = 1L;
	
	public HashMap<String, Double> pizzas;
	public HashMap<String, Double> ingredients = new HashMap<String, Double>();
	
	NumberFormat formatter = new DecimalFormat("#0.00");

	public PizzaBean() {
	    System.out.println("PizzaBean()");
	    
	    pizzas = new HashMap<String, Double>();
	    pizzas.put("Margarita",9.99);
	    pizzas.put("Hawai",11.0);
	    
	    ingredients.put("Cheese", 0.5);
	    ingredients.put("Champignon", 1.25);
	    ingredients.put("Salami", 1.0);
	    ingredients.put("Pineapple", 0.99);
	    ingredients.put("Bacon", 0.8);

	    
	    fetchAanbieding();
	}
	
	private void fetchAanbieding() {
		int day = Calendar.DAY_OF_WEEK;
		
		String pizza = "Aanbieding: ";
		double price = 0.0;
		
		switch(day) {
			case 1: pizza += "Americano"; price = 9.99; break;
			case 2: pizza += "Italiano"; price = 9.95; break;
			case 3: pizza += "Salami"; price = 8.95; break;
			case 4: pizza += "Gehakt"; price = 10.25; break;
			case 5: pizza += "Potato"; price = 9.59; break;
			case 6: pizza += "Paprika"; price = 10.59; break;
			case 7: pizza += "Cumcumber"; price = 8.44; break;
		}
		
		pizzas.put(pizza, price);
	}
	  
	public String getSelect() {
		System.out.println("PizzaBean.getSelect()");
		
		String html = "<select name=\"pizza\">";
		
		for (String key: pizzas.keySet()) {
			html += "<option value=\""+key+"\">"+key+" (&euro;"+formatPrice(pizzas.get(key))+")</option>";
		}
		
		html += "</select>";

		return html;
	}
	
	public String formatPrice(double price) {
		return formatter.format(price);
	}
	
	public Object[] getIngredients() {
		return ingredients.keySet().toArray();
	}
	
	/*public String getPizza() {
		return "depizza";
	}*/
	
	/*public double getPriceForPizza() {
		return pizzas.get(this.get("pizza"));
	}*/
}